package com.erp.dto;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.erp.domain.TDepartment;
import com.erp.domain.TRole;
import com.erp.domain.TUser;

public class User implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private Integer id;
	private String name;
	private String password;
	private Boolean sex;
	private Department department;
	private List<Role> roles = new ArrayList<Role>();
	private Date loginTime;
	private String loginLocation;
	private String ip;
	private String phone;
	private String email;
	private String description;

	public User() {
	}

	/**
	 * tDepartment,roles属性由service控制
	 * 
	 * @param tUser
	 */
	public User(TUser tUser) {
		this.id = tUser.getId();
		this.name = tUser.getName();
		this.password = tUser.getPassword();
		this.sex = tUser.getSex();

		TDepartment tDepartment = tUser.gettDepartment();
		if (tDepartment != null) {
			this.department = new Department(tUser.gettDepartment());
		}
		if (tUser.gettRoles() != null) {
			List<TRole> tRroles = tUser.gettRoles();
			for (TRole role : tRroles) {
				this.roles.add(new Role(role));
			}
		}

		this.loginTime = tUser.getLoginTime();
		this.loginLocation = tUser.getLoginLocation();
		this.ip = tUser.getIp();
		this.phone = tUser.getPhone();
		this.email = tUser.getEmail();
		this.description = tUser.getDescription();
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Boolean getSex() {
		return sex;
	}

	public void setSex(Boolean sex) {
		this.sex = sex;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public Date getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}

	public String getLoginLocation() {
		return loginLocation;
	}

	public void setLoginLocation(String loginLocation) {
		this.loginLocation = loginLocation;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

}